<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>选择任务</title>
  <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
  <link rel="stylesheet" type="text/css" href="../css/common.css"/>
  <link rel="stylesheet" href="../css/page_css/util.css">
</head>
<body>
  <div class="mui-content">
    <ul class="mui-table-view" id="LocationContent">
    	<script type="text/template" id="itemslist">
				{{each datas as item i}}
	      <li class="mui-table-view-cell mui-radio mui-left">
					<input name="sel_ads_radio" type="radio" onchange="TastId('{{item.wonum}}','{{item.description}}')">
	        <div class="list_item">
	          <div class="flex_center_between margin_b_8">
	            <p class="flex_first">
	              <label for="" class="no-padding width_auto">任务编号:&nbsp;</label>
	              <span>{{item.wonum}}</span>
	            </p>
	          </div>
	          <div class="flex_center_between">
	            <p class="flex_first">
	              <label for="" class="no-padding width_auto">任务描述:&nbsp;</label>
	              <span>{{item.description}}</span>
	            </p>
	          </div>
	        </div>
				</li>
				{{/each}}
				</script>
    </ul>

  </div>
  <script type="text/javascript" src="../script/api.js"></script>
  <script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
  <script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
  <script>
  	var page = 1;
		var loadEnd = false;
		var tastnum = '', description = '', searchText= '';
		apiready = function () {
			onLoadData(page,false);
			scrollToBottomHandler(function() {
				if (!loadEnd) { // 没有结束时继续加载
					page++;
					onLoadData(page,true);
				} else { // 告诉到底了
					EndToast('到底了');
				}
			})
			Refresh(function() {
				loadEnd = false;
				page = 1;
				onLoadData(page,false);
			});

			api.addEventListener({
		    name:'navitembtn'
			},function(ret, err){
			    if(ret.type == 'right'){
			    	if($api.dom("input[type='radio']:checked") == null){
			    		api.toast({
							    msg: '请选择一项!',
							    duration: 2000,
							    location: 'middle'
							});
			    		return
			    	} else{
			    		api.sendEvent({
						    name: 'TastId',
						    extra: {
						        tastnum: tastnum,
						        description: description
						    }
							});
				    	setTimeout(function(){
				    		api.closeWin();
				    	},100)
			    	}
			    }
		  })
		}
		function onLoadData (page,load) {
			ajaxrd("selectPlanTaskList", {
				linetype: api.pageParam.linetype,
				wonum: api.pageParam.wonum,
				pageNo: page,
				pageSize: 10
			}, function(ret, err) {
				api.refreshHeaderLoadDone();
				AddData('itemslist','LocationContent', ret.list, load);
				if (ret.list.length < 10) {
					loadEnd = true
				}
			})
		}
		var TastId = function (id, desc) {
			tastnum = id
			description = desc
		}
  </script>
</body>
</html>
